﻿Public Class OppskriftIngrediens

    Public Property kakeId As ULong
    Public Property ingrediensId As UInteger
    Public Property ant As UInteger

    Public Sub New(ByVal id As ULong)
        kakeId = id
    End Sub

    Private IngrediensOgAnt As New Dictionary(Of UInteger, UInteger)

    Public Sub lesInnNyOppskrift()
        Dim ingrediensListe As List(Of Ingrediens) = Ingrediens.FinnAlle()
        Dim ingrediensmengde As Integer
        For Each Ingrediens In ingrediensListe
            ingrediensmengde = InputBox("Tast inn antall enheter av denne ingrediens", Ingrediens.navn, 0)
            If ingrediensmengde > 0 Then
                IngrediensOgAnt.Add(Ingrediens.id, ingrediensmengde)
            End If
        Next
    End Sub

    Public Sub Lagre()

        Dim par As KeyValuePair(Of UInteger, UInteger)
        For Each par In IngrediensOgAnt
            Dim søkestreng As String = "INSERT INTO kakeoppskriftingrediens (kakeId,ingrediensId ,antall )  VALUES ('" & kakeId & "','" & par.Key & "','" & par.Value & "')"
            Dim dt As New DataTable
            dt = Database.Query(søkestreng)
        Next

        

    End Sub


End Class
